/**
 * @created 26-Feb-2006 12:50:20 p.m.
 * @version 0.0.1
 */ 
import SCUMMScenario.SCUMMScene;
import SCUMMGameControl.SCUMMActionBar;
import SCUMMCharacter.SCUMMActor;
import DialogueEngine.*;
import SCUMMCore.States.*;
import DialogueHandler.*;

class SCUMMCore.SCUMMGame {
 	private var nModeNumber:Number;
 	private var oCurrentScene:SCUMMScene;
 	private var oActionsBar:SCUMMActionBar;
 	private var oCurrentActorTalking:SCUMMActor;
 	private var oFlagContainer:Array;
	public var states:Array;
	public var nMainActorX:Number;
	public var nMainActorY:Number;
 	//In DialogHandler is paced ALL the game dialog
	//private var oDialogHandler:DialogHandler;
  	/** Property **/
 	public function get currentScene():SCUMMScene{
		return this.oCurrentScene;
	}
	public function set currentScene( value:SCUMMScene ):Void{
		this.oCurrentScene = value;
	}
	
 	public function SCUMMGame() {
 		this.nModeNumber = SCUMMGameModeDescriptor.EXPLORING;
		this.states = new Array();
 		oFlagContainer = new Array();
 	}
 	
 	public function setModeExploring(){
 		this.nModeNumber = SCUMMGameModeDescriptor.EXPLORING;
 	}
 	 public function setModeTalking(poActor:SCUMMActor){
 	 	this.oCurrentActorTalking = poActor;
 		this.nModeNumber=SCUMMGameModeDescriptor.TALKING;
 	}
 	
 	
 	public static function crateActor( pmcSprite:MovieClip ):SCUMMActor{
 		return new SCUMMActor(pmcSprite);
 	}
 	
 	public function createActionBar( pmcActionBar:MovieClip ):SCUMMActionBar{
 		this.oActionsBar = new SCUMMActionBar(pmcActionBar);
 		return this.oActionsBar;
 	}
 	
 	public function createCurrentScene( pmcScenario:MovieClip ) {
		if( pmcScenario == undefined )
			throw new Error("SCUMMScene - Error: The sprite of the main Scene can't be null");
			this.oCurrentScene =  new SCUMMScene( this, pmcScenario );
			return this.oCurrentScene;
 	}
 	/*
 	this function returns true if is exploring(mode related)
 	
 	@author: Pablo Weremczuk
 	@return: true if game mode is exploring
 	*/
	public function isExploring():Boolean{
		return nModeNumber==SCUMMGameModeDescriptor.EXPLORING;
	}
	//this function returns true if Talking
	public function isTalking():Boolean{
		return nModeNumber==SCUMMGameModeDescriptor.TALKING;
	}
	
	public function getOCurrentActorTalking():SCUMMActor {
		return oCurrentActorTalking;
	}

	public function setOCurrentActorTalking(oCurrentActorTalking:SCUMMActor):Void {
		this.oCurrentActorTalking = oCurrentActorTalking;
	}

	/**
	 *@return oActionsBar
	 */
	public function getActionsBar():SCUMMActionBar {
		return oActionsBar;
	}

	/**
	 *@param oActionsBar
	 */
	public function setActionsBar(oActionsBar:SCUMMActionBar):Void {
		this.oActionsBar = oActionsBar;
	}
	public function gotoRoom(strRoomDescriptor:String, nXWhereActorAppears:Number, nYWhereActorAppears:Number){
		this.currentScene.saveAllStates();
		this.nMainActorX = nXWhereActorAppears;
		this.nMainActorY = nYWhereActorAppears;
		this.currentScene.mc._parent.gotoAndStop(strRoomDescriptor);
	}
}